<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<md-dialog aria-label="warning-dialog">
  <form ng-submit="ctrl.generate()">
    <md-dialog-content layout-padding>
      <h4>{{ctrl.title}}</h4>
      <md-input-container ng-show="!ctrl.token" style="width: 100%;">
        <label>Name</label>
        <input type="text" md-maxlength="64" autofocus ng-model="ctrl.name" placeholder="What’s this token for?"/>
      </md-input-container>
      <div ng-if="ctrl.token">
        <h5>Make sure to copy your new personal access token now. You won’t be able to see it again.</h5>
        <span>
          <code>{{ctrl.token.token}}</code>
          <md-tooltip md-direction="right">Copy to clipboard</md-tooltip>
          <ng-md-icon size="20" style="fill: #424E5A;" icon="content_copy"
              ngclipboard data-clipboard-text="{{ctrl.token.token}}"
              ngclipboard-success="onClipboardSuccess()" role="button"></ng-md-icon>
        </span>
        <h6>Example of use:</h6>
        <span>
          <code>{{ctrl.getExampleOfUse(ctrl.token.token)}}</code>
          <md-tooltip md-direction="right">Copy to clipboard</md-tooltip>
          <ng-md-icon size="20" style="fill: #424E5A;" icon="content_copy"
                      ngclipboard data-clipboard-text="{{ctrl.getExampleOfUse(ctrl.token.token)}}"
                      ngclipboard-success="onClipboardSuccess()" role="button"></ng-md-icon>
        </span>
      </div>
    </md-dialog-content>
    <md-dialog-actions layout="row">
      <md-button ng-if="!ctrl.token" type="button" ng-click="ctrl.cancel()">Cancel</md-button>
      <md-button ng-if="!ctrl.token" class="md-raised md-primary" type="submit" ng-disabled="!ctrl.name">Generate</md-button>
      <md-button ng-if="ctrl.token" type="button" ng-click="ctrl.confirm()">OK</md-button>
    </md-dialog-actions>
  </form>
</md-dialog>
